package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;

import biz.FoodSizeBiz;
import biz.impl.FoodSizeBizImpl;
import entity.FoodSize;

@WebServlet("/admin/GetRateByFoodTypeIdServelt.html")
public class GetRateByFoodTypeIdServelt extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String foodTypeId =request.getParameter("foodType");
		int ftId = Integer.valueOf(foodTypeId);
		FoodSizeBiz foodSizeBiz = new FoodSizeBizImpl();
		List<FoodSize> foodSizeList = foodSizeBiz.queryFoodSizeByFoodTypeId(ftId);
		Gson gson = new Gson();
		String typeNamesJson = gson.toJson(foodSizeList);
		PrintWriter out = response.getWriter();
		out.print(typeNamesJson);//返回食物foodSize
		out.flush();
		out.close();
	}
	
	
	public static void main(String[] args) {
		
	}
	
	
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
